using System;
using System.Windows.Forms;
using System.Collections;
using Curriculum.Business.Manejadores;

namespace Curriculum.UI.Clases.ManejadorControles
{
	/// <summary>
	/// Summary description for ManejadorCombo.
	/// </summary>
	public class ManejadorCombo : ManejadorControles
	{
		public ManejadorCombo()
		{
		}
		public override void Cargar(System.Windows.Forms.Control ctrl, object value)
		{
			if(value != null)
				((ComboBox)ctrl).SelectedValue = (string) value;
		}
		public override void Inicializar(Control ctrl, object value)
		{
			ComboBox combo = ((ComboBox)ctrl);
			char separator=':';
			string[] valor = ((string)value).Split(separator);   
			string idAntecedente = valor[0];
			string idAtributo = valor[1];
			MasterData masterData = MasterData.GetInstancia();
			IList listaValores = masterData.GetListaValores(idAntecedente,idAtributo);
			combo.DisplayMember = "Valor";
			combo.ValueMember = "Id";
			combo.DataSource = listaValores;
		}
		public override string GetValor(Control ctrl)
		{
			return ((ComboBox)ctrl).SelectedValue.ToString();
		}

	}
}
